package com.joyance.springmvc.testhttp;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.joyance.springmvc.vo.Person;


public class TestAjax extends HttpServlet {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String age = req.getParameter("age");
        ServletOutputStream outputstream = resp.getOutputStream();
        String json = "{name:'" + name + "',age:'" + age + "'}";
        Person user = new Person();
        user.setAge(age == null ? 0 : Integer.parseInt(age));
        user.setName(name);
        outputstream.print(json);
        outputstream.close();
    }
}
